﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace NFit.Core.Config.Xml
{
    /// <summary>
    /// Represent a collection of fixture assembly
    /// </summary>
    [ConfigurationCollection(typeof(FixtureAssemblyElement), AddItemName = "fixturecatalog",
      CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class FixtureCatalogElementCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// Collection type
        /// </summary>
        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        /// <summary>
        /// Element name
        /// </summary>
        protected override string ElementName
        {
            get { return "assembly"; }
        }

        /// <summary>
        /// Create a new element
        /// </summary>
        /// <returns></returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new FixtureAssemblyElement();
        }

        /// <summary>
        /// Get element key
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as FixtureAssemblyElement).Name;
        }
    }
}
